package cn.itsource.org.mapper;

import cn.itsource.org.domain.Department;
import cn.itsource.org.query.DepartmentQuery;
import org.apache.commons.lang3.StringUtils;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 部门mapper
 */
public interface DepartmentMapper extends Mapper<Department> {

    List<Department> findPage(DepartmentQuery query);

    List<Department> findParentDepts();

    default List<Department> selectOldDirPath(String oldDirPath){
        Example example = new Example(Department.class);
        if(StringUtils.isNotBlank(oldDirPath)){
            example.and().andLike("dirPath","%"+oldDirPath+"%");
        }
        List<Department> departments = this.selectByExample(example);
        return departments;
    }
}
